<?php
/*
	| Created by 	: Erick Wahyudi Prakoso
	| Date 			: 11 Dec 2014
	| Email 		: erick.wp.mail@gmail.com
*/

	class Resize_image
	{
		public function __construct()
		{
			$this->CI  =& get_instance();
			$this->CI->load->helper('file');
		}
		
/*
	| $directory 	: direktori dari gambar yang akan di resize ukurannya (misal : direktori/upload/)
	| $thumb		: direktori yang akan ditaruh thumb (misal : direktori/upload/thumb/)
	| $file_name	: nama target file yang akan diresize (misal : mypicture.jpg)
*/
		
		public function do_resize($directory, $thumb, $file_name)
		{
			$config = array(
				'image_library' 	=> 'gd2',
				'source_image' 		=> $directory.'/'.$file_name,
				'new_image' 		=> $thumb,
				'maintain_ratio' 	=> TRUE,
				'create_thumb' 		=> TRUE,
				'thumb_marker' 		=> '_thumb',
				'width' 			=> 150,
				'height' 			=> 150
			);
			$this->CI->load->library('image_lib', $config);
		
			$this->CI->image_lib->resize();
		}
	}